home *** CD-ROM | disk | FTP | other *** search
- /* fstat.c, from page 358 of Turbo C Bible */
- #include <stdio.h>
- #include <sys\types.h>
- #include <sys\stat.h>
- #include <io.h>
- main ()
- {
- struct stat info;
- if (fstat (fileno (stdout), &info) != 0)
- {
- perror ("fstst failed");
- exit (1);
- }
- if ((info.st_mode & S_IFCHR) == S_IFCHR)
- {
- printf ("stdout is a device\n");
- }
- if ((info.st_mode & S_IFREG) == S_IFREG)
- {
- /* This means stdout has been redirected to a file */
- printf ("stdout is a regular file on drive %c\n", info.st_dev+65);
- }
- }